//
//  HWGameLiveFriendsListCell.swift
//  PlayWithProject
//
//  Created by 王昌健 on 2021/11/16.
//

import UIKit

class HWGameLiveFriendsListCell: UITableViewCell {
    var headImageView:UIImageView!
    var nameLabel:UILabel!
    var levelImageView:UIImageView!
    var lineView:UIView!
    
    class func cellWithTableView(tableView:UITableView) -> (HWGameLiveFriendsListCell) {
        let reUse:String = "HWGameLiveFriendsListCell"
        
        var cell = tableView.dequeueReusableCell(withIdentifier: reUse)
        
        if cell == nil {
            cell = HWGameLiveFriendsListCell.init(style: UITableViewCell.CellStyle.default, reuseIdentifier: reUse)
        }
        
        return cell as! HWGameLiveFriendsListCell
    }
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        initUI()
        initFrame()
    }
    
    func initUI() -> Void {
        selectionStyle = UITableViewCell.SelectionStyle.none
        backgroundColor = UIColor.clear
        
        headImageView = UIImageView()
        headImageView.layer.cornerRadius = 20
        headImageView.layer.masksToBounds = true
        headImageView.backgroundColor = .red
        contentView.addSubview(headImageView)
        
        nameLabel = HWLabel.createLabel(title: "adsfasdf", color: "#333333", font: 14)
        contentView.addSubview(nameLabel)
        
        levelImageView = UIImageView()
        levelImageView.backgroundColor = .black
        contentView.addSubview(levelImageView)
        
        lineView = UIView()
        lineView.backgroundColor = .colorWithHexString(hexString: "#CFCFCF")
        contentView.addSubview(lineView)
        
    }
    
    func initFrame() -> Void {
        headImageView.snp.makeConstraints { make in
            make.left.equalTo(15)
            make.width.height.equalTo(40)
            make.top.equalTo(10)
            make.bottom.equalTo(-10)
        }
        
        nameLabel.snp.makeConstraints { make in
            make.left.equalTo(headImageView.snp.right).offset(15)
            make.centerY.equalTo(headImageView)
        }
        
        levelImageView.snp.makeConstraints { make in
            make.left.equalTo(nameLabel.snp.right).offset(10)
            make.centerY.equalTo(nameLabel)
            make.width.equalTo(40)
            make.height.equalTo(16)
        }
        
        lineView.snp.makeConstraints { make in
            make.left.equalTo(nameLabel)
            make.bottom.equalTo(0)
            make.right.equalTo(-15)
            make.height.equalTo(1)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
